using System.Threading.Tasks;
using UnityEngine;

namespace JJYYCore
{
    public class ResourcesManager{
        private ResourcesLoaderBase loader;
        
        public T Load<T>(string id) where T:Object => loader.Load<T>(id);
        public async virtual Task<T> LoadAsync<T>(string id){
            var result = await loader.LoadAsync<T>(id);
            return result;
        }
        public void LoadCallBack<T>(string id, System.Action<T> loadedCallBack) where T : Object => loader.LoadCallBack(id,loadedCallBack);
        public void ReleaseRes<T>(T res) where T : Object => loader.ReleaseRes(res);
        public void ClearAll() => loader.ClearAll();


        public ResourcesManager(ResourcesLoaderFactory factory)
        {
            loader = factory.GetResourcesLoader();
        }
    }

    public abstract class ResourcesLoaderFactory{
        public abstract ResourcesLoaderBase GetResourcesLoader();
    }
}